﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;

namespace ch01
{
    public partial class Denglu : Form
    {
        public Denglu()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string name = this.txt_name.Text;
            string pwd = this.txt_pwd.Text;

            if (string.IsNullOrEmpty(name)||string.IsNullOrEmpty(pwd))
            {
                MessageBox.Show("您输入的信息不完整！");
                this.txt_name.Focus();
                return;
            }
            string sql =string.Format( "select count(1) from admin where id='{0}' and pwd='{1}'",name,pwd);
            int reader = Convert.ToInt32(DBHelper.SelectOne(sql));
            if (reader > 0)
            {
                FrmMain fm = new FrmMain();
                fm.Show();
            }
            else
            {
                MessageBox.Show("您输入的用户名或密码错误！");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("您确定要退出吗！","提示信息！",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
            if (dr==DialogResult.Yes)
            {
                this.Close();
            }
        }
    }
}
